const http = require('http')
const path = require('path')
const fs = require('fs')

const server = http.createServer()

server.listen(4000, console.log('服务器启动成功'))

server.on('request', (req, res) => {
  // 读取到文件 index.html 文件
  const filePath = path.join(__dirname, './views', '/index.html')
  fs.readFile(filePath, 'utf-8', (err, data) => {
    if (err) return console.log('读取错误')
    res.end(data)
  })
})
